<template>
  <div class="patient-info">
    <div class="patient-info-inside">
      <div class="header">
        <div class="left item">
          <img alt="左侧" src="@/components/assets/images/design/1-12.webp" />
        </div>
        <!-- <div class="middle item">请输入药品信息首字母查询</div> -->
         <slot class="middle item">默认内容</slot>
        <div class="right item">
          <img alt="右侧" src="@/components/assets/images/design/1-12.webp" />
        </div>
      </div>
      <div class="patient-info-area">
        <div class="input-display">
          {{inputTitle}}
          <input
            type="text"
            readonly
            v-model="inputValue"
          />
        </div>
        <KeyboardContainer  @input="setKeyboardContainer"/>
        <div class="sure-button-box">
          <div @click="postKeyboardContainer">
            确定
          </div>
          
        </div>
      </div>
    </div>
  </div>
</template>

<script>
import { v4 as uuid } from "uuid";
import { AndroidToWeb, buildParentApi } from "@/utils/designer/util";
import KeyboardContainer from "@sc/DRCbiz/comps/keyboard-container";
let buildParent = buildParentApi();
export default {
  name: "inputLetterKeyboard",

  componentName: "inputLetterKeyboard",

  components: {
    KeyboardContainer,
  },
  props:{
    inputTitle:{
      type: String,
      default: ''
    }
  },
  data() {
    return {
      widget: uuid(),
      inputValue: '',
    };
  },

  computed: {
    patientInfo() {
      return this.$store.getters["DRCbiz/getPatientInfo"];
    },
    // 步骤
    stepInfo() {
      return this.$store.getters["DRCbiz/getStepsInfo"];
    },
  },

  mounted() {},

  methods: {
    /**
     * @name 点击了确定
     */
    postKeyboardContainer(){
      this.$emit('handleSure',this.inputValue)
    },
    /**
     * @name 键盘输入
     */
    setKeyboardContainer(value) {
      if (value === 'Back') {
        // 删除最后一个字符
        this.inputValue = this.inputValue.slice(0, -1);
      } else {
        // 追加输入字符
        this.inputValue += value;
      }
    },
    async handlePre() {
      this.widget = uuid();
      let stepInfo = parseInt(this.stepInfo);
      if (stepInfo === 1) {
        await this.$router.push({
          path: `/DRCbizList`,
        });
      } else {
        await this.$store.dispatch("DRCbiz/setStepsInfo", --stepInfo);
      }
      switch (parseInt(this.stepInfo)) {
        case 2:
          let cardTypeInfo = this.cardTypeInfo;
          Reflect.set(cardTypeInfo, "cardNo", null);
          await this.$store.dispatch("DRCbiz/setCardTypeInfo", cardTypeInfo);
          buildParent.executeParentMethod("openScan");
          break;
      }
    },
    postUserMsg(row) {
      // this.$emit('postUserMsg',row)
      let devInfo = JSON.parse(localStorage.getItem("deviceInfo"));
      switch (row.value) {
        case "1": // ZYQueryPatientInfo
          let ZYQueryPatientInfoInfoParams = {
            Request: {
              deviceIp: devInfo.screenIp,
              flowId: uuid(),
              timestamp: this.$day().valueOf(),
              terminalNo: devInfo?.screenId, // 自助机设备终端	C	可空	根据医院实际情况
              method: "ZYQueryPatientInfo",
              patientId: "00210277", // 住院号 是否为空根据医院情况
              // cardNo: this.patientInfo.cardNo, // 卡号
              // cardType: this.patientInfo.cardType, // 卡类型
              patientName: "", // 开始时间
            },
          };
          let ZYQueryPatientInfoParams = this.$x2js.js2xml(
            ZYQueryPatientInfoInfoParams
          );
          buildParent.executeParentMethod(
            "axiosRep",
            ZYQueryPatientInfoParams,
            "ZYQueryPatientInfo"
          );
          break;
          break;
        case "2":
          let ZYQueryBillDetailInfoParams = {
            Request: {
              deviceIp: devInfo.screenIp,
              flowId: uuid(),
              timestamp: this.$day().valueOf(),
              terminalNo: devInfo?.screenId, // 自助机设备终端	C	可空	根据医院实际情况
              method: "ZYQueryBillDetail",
              patientHosId: "379857", // 住院号 是否为空根据医院情况
              cardNo: "", // 卡号
              cardType: "", // 卡类型
              startDate: "2025-02-21", // 开始时间
              endDate: "2025-02-21", // 结束时间
              birthday: "1969-06-19", // 生日
            },
          };

          let ZYQueryBillDetailQueryParams = this.$x2js.js2xml(
            ZYQueryBillDetailInfoParams
          );
          buildParent.executeParentMethod(
            "axiosRep",
            ZYQueryBillDetailQueryParams,
            "ZYQueryBillDetail"
          );
          break;
      }
    },
  },
};
</script>

<style scoped lang="scss">
@import "./assets/style";
</style>